/**
	* Copyright (c) minuteproject, minuteproject@gmail.com
	* All rights reserved.
	* 
	* Licensed under the Apache License, Version 2.0 (the "License")
	* you may not use this file except in compliance with the License.
	* You may obtain a copy of the License at
	* 
	* http://www.apache.org/licenses/LICENSE-2.0
	* 
	* Unless required by applicable law or agreed to in writing, software
	* distributed under the License is distributed on an "AS IS" BASIS,
	* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	* See the License for the specific language governing permissions and
	* limitations under the License.
	* 
	* More information on minuteproject:
	* twitter @minuteproject
	* wiki http://minuteproject.wikispaces.com 
	* blog http://minuteproject.blogspot.net
	* 
*/
/**
	* template reference : 
	* - name : OpenxavaDomainObjectUML
	* - file name : DomainObjectUMLJPAAnnotationOXAnnotationV4.vm
*/
package sistema_oficial.sistema_oficial.domain.sistemaoficial;

//MP-MANAGED-ADDED-AREA-BEGINNING @import@
//MP-MANAGED-ADDED-AREA-ENDING @import@
import java.sql.*;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;

import javax.persistence.*;
import org.openxava.annotations.*;

import calculators.*;

import sistema_oficial.sistema_oficial.domain.sistemaoficial.CotizacionVenta;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.FacturaVenta;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.Categoria;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.SubcuentaMayor;

/**
 *
 * <p>Title: Cliente</p>
 *
 * <p>Description: Domain Object describing a Cliente entity</p>
 *
 */
@Entity (name="Cliente")
@Table (name="cliente")
@Views({
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @view-base-cliente@
	@View(
		name="base",
		members=
        "" 	
        + "codigo  ; "
        + "nombre  ; "
        + "direccion  ; "
        + "telefono  ; "
        + "email  ; "
        + "contacto  ; "
        + "categoriaIdentificador  ; "
        + "subcuentaMayorCodigo  ; "
		),
//MP-MANAGED-UPDATABLE-ENDING
	@View(
		name="Create", 
		extendsView="base"
	),
	@View(
		name="Update", 
		extendsView="base",
        members=
          "" 	
	    + "cotizacionVenta { cotizacionVentaClienteViaClienteCodigo };" 
	    + "facturaVenta { facturaVentaClienteViaClienteCodigo };" 
	),
	@View(extendsView="base",
        members=
          "" 	
	    ),
    @View(name="clienteDEFAULT_VIEW", 
	   members=
          " codigo ;" 	
        + "nombre  ; "
        + "direccion  ; "
        + "telefono  ; "
        + "email  ; "
        + "contacto  ; "
	),
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @view-reference-cliente@
    @View(name="reference", 
       extendsView="clienteDEFAULT_VIEW"
//MP-MANAGED-UPDATABLE-ENDING
    )
})

@Tabs({
@Tab(
properties=
     " codigo "
    +",  nombre "
    +",  direccion "
    +",  telefono "
    +",  email "
    +",  contacto "
)
,
@Tab(
name = "ClienteTab",
properties=
     " codigo "
    +",  nombre "
    +",  direccion "
    +",  telefono "
    +",  email "
    +",  contacto "
)
,
@Tab(
name = "ClienteTabWithRef",
properties=
     " codigo "
    +",  nombre "
    +",  direccion "
    +",  telefono "
    +",  email "
    +",  contacto "
)
})
//MP-MANAGED-ADDED-AREA-BEGINNING @class-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @class-annotation@
public class Cliente {

    @Id @Column(name="codigo" ,length=50)
    private String codigo; 

//MP-MANAGED-ADDED-AREA-BEGINNING @nombre-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @nombre-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-nombre@
    @Column(name="nombre",  length=100, nullable=false,  unique=false)
    @Required
    private String nombre;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @direccion-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @direccion-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-direccion@
    @Column(name="direccion",  length=100,  nullable=true,  unique=false)
    private String direccion;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @telefono-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @telefono-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-telefono@
    @Column(name="telefono",  length=25,  nullable=true,  unique=false)
    private String telefono;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @email-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @email-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-email@
    @Column(name="email",  length=50,  nullable=true,  unique=false)
    private String email;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @contacto-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @contacto-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-contacto@
    @Column(name="contacto",  length=25,  nullable=true,  unique=false)
    private String contacto;	
//MP-MANAGED-UPDATABLE-ENDING


//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @parent-Categoria-cliente@
    @ManyToOne (fetch=FetchType.LAZY ,optional=false) //remove optional=false to aggragate but leads to a side effect when going directly to the entity: required check is not performed=> if no set DB check constraint is raised...
    @JoinColumn(name="categoria_identificador", nullable=false,  unique=false  )
    @ReferenceView ("reference") 
    @DefaultValueCalculator(CategoriaCalculator.class)
    private Categoria categoriaIdentificador; 
    
//MP-MANAGED-UPDATABLE-ENDING
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @parent-SubcuentaMayor-cliente@
    @ManyToOne (fetch=FetchType.LAZY ,optional=false) //remove optional=false to aggragate but leads to a side effect when going directly to the entity: required check is not performed=> if no set DB check constraint is raised...
    @JoinColumn(name="subcuenta_mayor_codigo", nullable=false,  unique=false  )
    @ReferenceView ("reference") 
    private SubcuentaMayor subcuentaMayorCodigo; 
    
//MP-MANAGED-UPDATABLE-ENDING
//children
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @child-cotizacionVentaClienteViaClienteCodigo-cliente@
    @OneToMany (targetEntity=sistema_oficial.sistema_oficial.domain.sistemaoficial.CotizacionVenta.class, fetch=FetchType.LAZY, mappedBy="clienteCodigo", cascade=CascadeType.REMOVE)//, cascade=CascadeType.ALL)
    private Set <CotizacionVenta> cotizacionVentaClienteViaClienteCodigo = new HashSet<CotizacionVenta>(); 
   
//MP-MANAGED-UPDATABLE-ENDING
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @child-facturaVentaClienteViaClienteCodigo-cliente@
    @OneToMany (targetEntity=sistema_oficial.sistema_oficial.domain.sistemaoficial.FacturaVenta.class, fetch=FetchType.LAZY, mappedBy="clienteCodigo", cascade=CascadeType.REMOVE)//, cascade=CascadeType.ALL)
    private Set <FacturaVenta> facturaVentaClienteViaClienteCodigo = new HashSet<FacturaVenta>(); 
   
//MP-MANAGED-UPDATABLE-ENDING
//m2m
    /**
    * Default constructor
    */
    public Cliente() {
    }


    public String getCodigo() {
        return codigo;
    }
	
    public void setCodigo (String codigo) {
        this.codigo =  codigo;
    }
    

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-nombre@
    public String getNombre() {
        return nombre;
    }
	
    public void setNombre (String nombre) {
        this.nombre =  nombre;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-direccion@
    public String getDireccion() {
        return direccion;
    }
	
    public void setDireccion (String direccion) {
        this.direccion =  direccion;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-telefono@
    public String getTelefono() {
        return telefono;
    }
	
    public void setTelefono (String telefono) {
        this.telefono =  telefono;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-email@
    public String getEmail() {
        return email;
    }
	
    public void setEmail (String email) {
        this.email =  email;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-contacto@
    public String getContacto() {
        return contacto;
    }
	
    public void setContacto (String contacto) {
        this.contacto =  contacto;
    } 
//MP-MANAGED-UPDATABLE-ENDING


    public Categoria getCategoriaIdentificador () {  //
    	return categoriaIdentificador;
    }
	
    public void setCategoriaIdentificador (Categoria categoriaIdentificador) {
    	this.categoriaIdentificador = categoriaIdentificador;//this.categoriaIdentificador = categoria;
    }
    public SubcuentaMayor getSubcuentaMayorCodigo () {  //
    	return subcuentaMayorCodigo;
    }
	
    public void setSubcuentaMayorCodigo (SubcuentaMayor subcuentaMayorCodigo) {
    	this.subcuentaMayorCodigo = subcuentaMayorCodigo;//this.subcuentaMayorCodigo = subcuentaMayor;
    }

    public Set<CotizacionVenta> getCotizacionVentaClienteViaClienteCodigo() {
        if (cotizacionVentaClienteViaClienteCodigo == null){
            cotizacionVentaClienteViaClienteCodigo = new HashSet<CotizacionVenta>();
        }
        return cotizacionVentaClienteViaClienteCodigo;
    }

    public void setCotizacionVentaClienteViaClienteCodigo (Set<CotizacionVenta> cotizacionVentaClienteViaClienteCodigo) {
        this.cotizacionVentaClienteViaClienteCodigo = cotizacionVentaClienteViaClienteCodigo;
    }	
    
    public void addCotizacionVentaClienteViaClienteCodigo (CotizacionVenta cotizacionVenta) {
    	    getCotizacionVentaClienteViaClienteCodigo().add(cotizacionVenta);
    }
    
    public Set<FacturaVenta> getFacturaVentaClienteViaClienteCodigo() {
        if (facturaVentaClienteViaClienteCodigo == null){
            facturaVentaClienteViaClienteCodigo = new HashSet<FacturaVenta>();
        }
        return facturaVentaClienteViaClienteCodigo;
    }

    public void setFacturaVentaClienteViaClienteCodigo (Set<FacturaVenta> facturaVentaClienteViaClienteCodigo) {
        this.facturaVentaClienteViaClienteCodigo = facturaVentaClienteViaClienteCodigo;
    }	
    
    public void addFacturaVentaClienteViaClienteCodigo (FacturaVenta facturaVenta) {
    	    getFacturaVentaClienteViaClienteCodigo().add(facturaVenta);
    }
    



//MP-MANAGED-ADDED-AREA-BEGINNING @implementation@
//MP-MANAGED-ADDED-AREA-ENDING @implementation@

}
